﻿using FirstFloor.ModernUI.Presentation;
using FirstFloor.ModernUI.Windows.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;

namespace plust.Content
{
    class CategoriaViewModel : INotifyPropertyChanged, IDataErrorInfo
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private string nombre_categoria;
        private string descripcion;

        public string NombreCategoria
        {
            get { return this.nombre_categoria; }
            set
            {
                this.nombre_categoria = value;
                OnPropertyChanged("NombreCategoria");
            }
        }

        public string Descripcion
        {
            get { return this.descripcion; }
            set
            {
                this.descripcion = value;
                OnPropertyChanged("Descripcion");
            }
        }

        public string Error
        {
            get { return null; }
        }

        public string this[string columnName]
        {
            get
            {
                if (columnName == "NombreCategoria")
                {
                    return string.IsNullOrEmpty(this.nombre_categoria) ? "Valor Requerido" : null;
                }

                if (columnName == "Descripcion")
                {
                    return string.IsNullOrEmpty(this.descripcion) ? "Valor Requerido" : null;
                }

                return null;
            }
        }

        protected void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }  
    }
}
